package com.opener.web.spring.db;

import com.opener.common.encrypt.EncryptUtils;
import org.apache.commons.dbcp.BasicDataSource;

/**
 *
 * @author baboy
 * @date 23/06/2017
 */
public class EncryptDataSource extends BasicDataSource {

    @Override
    public void setPassword(String password) {
        String c = EncryptUtils.decrypt(password);
        if (c == null){
            c = password;
        }
        super.setPassword(c);
    }
    @Override
    public void setUsername(String username){
        String c = EncryptUtils.decrypt(username);
        if (c == null){
            c = username;
        }
        super.setUsername(c);
    }
    @Override
    public void setUrl(String url){
        String c = EncryptUtils.decrypt(url);
        if (c == null){
            c = url;
        }
        super.setUrl(c);
    }
    @Override
    public void setDriverClassName(String driverClassName){
        String c = EncryptUtils.decrypt(driverClassName);
        if (c == null){
            c = driverClassName;
        }
        super.setDriverClassName(c);
    }
}
